package com.csy.feign;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.csy.feign.user.fallback.UserServiceApiFallbackFactory;

//import com.citycloud.cm.feign.servi.pic.fallback.PicCameraApiFallbackFactory;
//import com.citycloud.cm.feign.sys.fallback.SysServiceApiFallbackFactory;
//import com.citycloud.cm.feign.time.fallback.TimeServiceApiFallbackFactory;
//import com.citycloud.cm.feign.video.fallback.VideoServiceApiFallbackFactory;

import lombok.extern.slf4j.Slf4j;

/**
 * 两个作用: 1. 配置OpenFeign的全局配置; 2. 申明@EnableFeignClients注解使Feign接口们生效
 *
 * @author 吴樑
 * @version 1.0
 * @date 2021年12月28日
 */
@Slf4j
@Configuration
@EnableFeignClients
public class FeignConfig {
	@Value("${feign.sentinel.enabled}")
	private String flag;

	/* ------------------ 这里统一管理降级工厂Bean，所有的FallbackFactory都在这个配置里统一管理 ------------------ */
	
	@Bean
	UserServiceApiFallbackFactory UserServiceApiFallbackFactory() {
		log.info(">>>> [FeignConfig](降级开关)feign.sentinel.enabled={}.", flag);
		return new UserServiceApiFallbackFactory();
	}

//	/**
//	 * 计时模块降级工厂Bean
//	 * 
//	 * @return {@link TimeServiceApiFallbackFactory}
//	 */
//	@Bean
//	public TimeServiceApiFallbackFactory timeServiceApiFallbackFactory() {
//		return new TimeServiceApiFallbackFactory();
//	}
//
//    /**
//     * Video模块降级工厂
//     * @return	{@link VideoServiceApiFallbackFactory}
//     */
//    @Bean
//    public VideoServiceApiFallbackFactory videoServiceApiFallbackFactory() {
//        return new VideoServiceApiFallbackFactory();
//    }
//
//    /**
//     * 系统设置模块降级工厂
//     *
//     * @return
//     * @author Yvan
//     * @date 2022年2月22日
//     */
//    @Bean
//    public SysServiceApiFallbackFactory sysServiceApiFallbackFactory() {
//        return new SysServiceApiFallbackFactory();
//    }
//
//    /**
//     * PicCameraApi的降级工厂
//     * @return	{@link PicCameraApiFallbackFactory}
//     */
//    @Bean
//    public PicCameraApiFallbackFactory picCameraApiFallbackFactory() {
//    	return new PicCameraApiFallbackFactory();
//    }
}
